<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" href="../public/layui/css/layui.css"/>
		<script src="../public/js/jquery-1.11.1.min.js"></script>
		<title></title>
		<style>
			.mt5{margin-top: 5px}
		</style>
	</head>

	<body style="margin: 15px;">
		<form class="layui-form layui-form-pane" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">区块名</label>
				<div class="layui-input-block">
					<input type="text" name="one"  placeholder="请输入"  class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">摄像头</label>
				<div class="layui-input-block">
					<select id="camera" name="two" lay-filter="aihao">
						<option value="">请选择摄像头</option>
					</select>
				</div>
			</div>


		</form>
		<div class="video" id="video" style="margin-top: 20em;position: absolute;visibility: hidden;height: 0">
			<embed style="position: absolute;z-index: -1" align="center" type="application/webvideo-plugin-kit" width="100%" height="100%" name="webVideoCtrl20171109090246" wndtype="1" playmode="2" colors="">
		</div>
		 <div style="text-align: center;">
		 	<button class="layui-btn layui-btn-sm layui-btn-normal" style="margin-right:80px;" onclick="saveData()">保存并关闭</button>
		 	<button class="layui-btn layui-btn-sm layui-btn-danger" onclick="closelayer()">关闭</button>
		 </div>
		<script src="../public/layui/layui.js"></script>
		<!--海康插件核心JS文件-->
		<script type="text/javascript" src="../public/js/webVideoCtrl.js"></script>
		<!--操作文件-->
		<script  src="../public/js/video1.js"></script>
	</body>
	<script>
		var form="";
		var cameraid=[];
		layui.use(['form',], function() {
			form = layui.form;
			form.on('select(aihao)',function(data){
				for(var i=0;i<$('#camera').next().children('dl').children('dd').length;i++){
					if($('#camera').next().children('dl').children('dd').eq(i).hasClass('layui-this')){
						console.log($('#camera').children('option').eq(i).data("camera"));
						cameraid=$('#camera').children('option').eq(i).data("camera").id;
						console.log(cameraid)

					}
				}
			});

		});
		//视频窗口的大小
		var winWidth = 787;
		var winHeight = 541;
		var isCenter = true;
		var controlOrLoop = "control";
		$(document).ready(function() {
//			每个区域的账号密码，不同区域不同，响应事件写在区域的select点击事件里
			var public_ip="27.155.177.209:8889";
			var public_prototocol="1";
			var public_port="8889";
			var public_username="admin";
			var public_userpwd="a123456789";
      		login(public_ip,public_prototocol,public_port,public_username,public_userpwd);

		});



		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		function closelayer(){
			parent.layer.close(index); //再执行关闭
		}
		function saveData(){
			var infor1=[];
			var name= $('input[name=one]').val();
			infor1.push({"palcename":$('input[name=one]').val(),"camera":$('#camera option:selected').text(),"ID":cameraid});
			parent.addInfo(infor1);
			parent.layer.close(index); //再执行关闭
		}


	</script>
</html>